class Solution 
{
public:
	int lastStoneWeight(vector<int>& stones) 
	{
		priority_queue<int> max_heap(stones.begin(),stones.end());             // 最大堆
		while (max_heap.size() > 1)
		{
			int elem1 = max_heap.top();
			max_heap.pop();
			int elem2 = max_heap.top();
			max_heap.pop();

			if (elem1 != elem2)
			{
				max_heap.push(abs(elem2 - elem1));
			}

		}
		return max_heap.empty() ? 0 : max_heap.top();
	}
};